//
//  GeneratorController.m
//  Generator5x7
//
//  Created by Francis Perea on 12/05/08.
//  Copyright 2008 Francis Perea. All rights reserved.
//

#import "GeneratorController.h"



@implementation GeneratorController
- (id)init
{
 self=[super init];    
 generator=[[[Generator alloc]init] retain];
 return self;
}

- (void)awakeFromNib 
{ 
 [self Refresca];
} 

- (void)Refresca
{
 [Col1 setStringValue: [NSString stringWithFormat:@"%0.2X",[[generator.valores objectAtIndex:0] intValue]]];
 [Col1 display];
 [Col2 setStringValue: [NSString stringWithFormat:@"%0.2X",[[generator.valores objectAtIndex:1] intValue]]];
 [Col2 display];
 [Col3 setStringValue: [NSString stringWithFormat:@"%0.2X",[[generator.valores objectAtIndex:2] intValue]]];
 [Col3 display];
 [Col4 setStringValue: [NSString stringWithFormat:@"%0.2X",[[generator.valores objectAtIndex:3] intValue]]];
 [Col4 display];
 [Col5 setStringValue: [NSString stringWithFormat:@"%0.2X",[[generator.valores objectAtIndex:4] intValue]]];
 [Col5 display];
}

- (IBAction)Maneja:(id)sender 
{
  int col, row;
  [sender getRow :&row column:&col ofCell:[sender selectedCell]];
  [generator Enciende:col :row :[[sender selectedCell] state]];
  [self Refresca];
}

- (IBAction)Copia:(id)sender
{ 
 NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
 [pasteboard declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner: NULL];
 [pasteboard setString:(NSString *)generator.cadena forType: NSStringPboardType];
}

- (IBAction)Borra:(id)sender
{
 int col,row;
 for (row=0; row<7; row++)
  for (col=0; col<5; col++){
   [generator Enciende:col :row :NSOffState];
   [botones setState:NSOffState atRow:row column:col];
  }
  [self Refresca];
}

-(void)dealloc{
 [generator release];
 [super dealloc];
}
@end
